import 'package:dio/dio.dart';
import 'package:smart_shoes/define/define_block.dart';
import 'package:smart_shoes/define/define_url.dart';
import 'package:smart_shoes/models/message.dart';

import 'package:smart_shoes/network/dio_client.dart';
import 'package:get/get_connect/http/src/response/response.dart' hide Response;

class LoginManager {
  ///获取短信验证码,默认为 123456
  static loginCode(
    Map<String, dynamic> param,
    NetworkMessageCallBack callBack,
  ) async {
    Response<dynamic> _ = await DioClient().doPost(
      NetworkingUrls.code,
      queryParameters: param,
    );
    bool flag = true;
    String reason = "发送成功，请注意查收";
    callBack(Message(flag, reason));
  }

  static passwordLogin(
    Map<String, dynamic> param,
    NetworkMessageCallBack callBack,
  ) async {
    Response<dynamic> response = await DioClient().doPost(
      NetworkingUrls.code,
      queryParameters: param,
    );
    bool flag = true;
    if (response.data['code'] != 200) {
      flag = false;
    }

    String reason = response.data['message'];
    callBack(Message(flag, reason));
  }

  static checkCode(
    Map<String, dynamic> param,
    NetworkMessageCallBack callBack,
  ) async {
    Response<dynamic> _ = await DioClient().doPost(
      NetworkingUrls.code,
      queryParameters: param,
    );
    bool flag = true;
    String reason = "发送成功，请注意查收";
    callBack(Message(flag, reason));
  }
}
